<div class="row">
 
    <div class="span10"> 
        <div id="<*$controller*>">
        
              <div class="clearfix txtleft search" style="background-color:#f8f8f8; padding:10px; margin:10px 0px;" >  
                   <form  name="form1"  method="get" class="form-horizontal" action="/<*$controller*>/index"> 
                      机构:<select id="jigou" name="groups"  onchange="getSchool(this.value)"></select>
                      校园:<select id="school" name="school"  onchange="getClass(this.value)"></select> 
                      班级:<select id="class" name="class" ></select>  
                      <input type="submit" class="btn btn-success"  value="查询" >
                     <!-- <input type="button" class="btn btn-success" value="清空查询" onclick="window.location='/bindcode/index'" >-->
                   </form>
                </div>	 
        <*if $studentlist|@count neq 0*>      
        <table class="table">
            <tr>
                <th style="width:20%;">中文名称</th>
                <th style="width:20%;">英文名称</th>
                <th style="width:20%;">是否绑定</th>
                <th style="width:20%;">绑定码</th> 
                <th>&nbsp;</th>
            </tr>
          
            <*foreach from=$studentlist item=item key=key*>
            <tr>
                <td><*$item.cnname*></td>
                <td><*$item.enname*></td>
                <td><*if $item.uid neq 0*><i class="icon-ok"></i><*else*><i class="icon-remove"></i><*/if*></td>
                <td><*$item.bindcode*></td> 
                <td>&nbsp;</td>
            </tr>
            <*/foreach*>
             <tr>
                <th style="width:20%;" >总计</th> 
                <th style="width:20%;"><*$studentlist|count*></th>
                <th style="width:20%;" colspan="2">已绑定：<*$unbind*></th> 
                <th>&nbsp;</th>
            </tr> 
           </table>   
         <*/if*>    
        </div>
    </div>
</div>
<script type="text/javascript" src="/js/prototype.js"></script>
<script type="text/javascript" > 
 window.onload=function(){
	 jigou(); 

	if('<*$groups*>' != ''){
		getSchool('<*$groups*>');
	}
	if('<*$school*>' != ''){
		getClass('<*$school*>');
	}

 }
function jigou()
{   
   
	var url     = '/<*$controller*>/groups/'; 
	//var pars = '&classname=' + classname +'&name=' + name+'&studentno=' + studentno +'&attend=' + attend + '&leave=' + leave + '&reason=' + reason;
	var pars = '';
	var myAjax = new Ajax.Request( url, { method: 'post', parameters: pars, onComplete:showResponse_course});

} 
function showResponse_course(originalRequest)
{
	 //alert(originalRequest.responseText);  
	 document.all.form1.groups.innerHTML='<option value="0" >==请选择==</option>'+originalRequest.responseText;
	
	if('<*$groups*>' != ''){
	 jsSelectIsExitItem(document.all.form1.groups,'<*$groups*>');
	}
}  

function getSchool(a)
{  
	var url  = '/<*$controller*>/schoollist/'; 
	//var pars = '&classname=' + classname +'&name=' + name+'&studentno=' + studentno +'&attend=' + attend + '&leave=' + leave + '&reason=' + reason;
	var pars = '&id=' + a;
	var myAjax = new Ajax.Request( url, { method: 'post', parameters: pars, onComplete:showResponse_school});

} 
function showResponse_school(originalRequest)
{
	{    //alert(originalRequest.responseText);  
		 document.all.form1.school.innerHTML='<option value="0" >==请选择==</option>'+originalRequest.responseText;
		 if('<*$school*>' != ''){
				jsSelectIsExitItem(document.all.form1.school,'<*$school*>');
			}
	 } 
} 



function getClass(a)
{  
     
	var url  = '/<*$controller*>/classlist/'; 
	//var pars = '&classname=' + classname +'&name=' + name+'&studentno=' + studentno +'&attend=' + attend + '&leave=' + leave + '&reason=' + reason;
	var pars = '&id=' + a;
	var myAjax = new Ajax.Request( url, { method: 'post', parameters: pars, onComplete:showResponse_class});

} 
function showResponse_class(originalRequest)
{
	{    //alert(originalRequest.responseText);  
		 document.all.form1.class.innerHTML='<option value="0" >==请选择==</option>'+originalRequest.responseText;
 		 if('<*$classid*>' != ''){
				jsSelectIsExitItem(document.all.form1.class,'<*$classid*>');
			}


	 } 
} 


function jsSelectIsExitItem(objSelect, objItemValue) {
	//alert(objSelect.options.length);
    for (var i = 0; i < objSelect.options.length; i++) {
        if (objSelect.options[i].value == objItemValue) { 
			objSelect.options[i].selected=true;
        	 break;
        }
    }
    return 1;
}  


</script>

